using Cinemachine;
using DG.Tweening;
using UnityEngine;


public class TestScripts2 : MonoBehaviour
{
    [SerializeField]
    Test testData;

    [SerializeField]
    SpriteRenderer circle;

    Rigidbody2D rigidbody2D;

    CinemachineImpulseSource impulseSource;

    Tween tweener;
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log(testData.Sheet1.Count);

        tweener = DOVirtual.DelayedCall(5, () =>
        {
            Debug.Log("DelayedCall Test");
        });
        rigidbody2D = GetComponent<Rigidbody2D>();
        impulseSource = GetComponent<CinemachineImpulseSource>();

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            tweener.Kill();
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            //var trangleObj = Pool.GetInstance().GetObj("Prefabs/Triangle");
            //trangleObj.transform.position = new Vector3(Random.Range(0, 10), 2, 1);

            //DOVirtual.DelayedCall(2, () =>
            //{
            //    Pool.GetInstance().DestroyObj(trangleObj);
            //});
            rigidbody2D.AddForce(new Vector2(0, 14), ForceMode2D.Impulse);
            impulseSource.GenerateImpulse();
        }

        if (Input.GetKey(KeyCode.A))
        {
            rigidbody2D.velocity = (new Vector2(-5, rigidbody2D.velocity.y));
        }
        else if (Input.GetKey(KeyCode.D))
        {
            rigidbody2D.velocity = (new Vector2(5, rigidbody2D.velocity.y));
        }
        else
        {
            rigidbody2D.velocity = (new Vector2(0, rigidbody2D.velocity.y));
        }
    }

    private void OnDrawGizmosSelected()
    {
        Gizmos.DrawWireCube(Vector3.zero, new Vector3(45, 45, 45));
    }
}
